
#ifndef SHOGISERVER_H_INCLUDED
#define SHOGISERVER_H_INCLUDED

// QT includes
#include <QtCore> 
#include <QTcpServer>
#include <QtNetwork>
// Project specific
#include "ssmainwindow.h"
#include "shogiregistry.h"
#include "shogiplayer.h"
#include "../common/shogidef.h"
#include "../common/shogicommand.h"

class ShogiPlayer;

class ShogiServer : public QObject
{
	Q_OBJECT
public slots:
	void newPlayerConnected();
	void playerChangedState(Player p);
	void playerWaitingForOtherPlayerToFinishState(Player p);
	void sendCommand(Player p, ShogiCommand cmd);
	

signals:
	void signalForceStateChange(GameState s);
	


public:
	ShogiServer();
	virtual ~ShogiServer();
	bool start();

	
	static const int SERVER_PORT = 31416;
protected:
	
	void receivedCommand(Player p);

private:
	ShogiPlayer* m_players[2];	
	QTcpServer	m_listener;
	
};

#endif // SHOGISERVER_H_INCLUDED





